Skip to content

Fix test suite hanging indefinitely by adding timeouts and proper cleanup#366

Merged
mariuz merged 2 commits intomasterfrom
copilot/fix-test-errors-action-run
Feb 13, 2026
Merged

Fix test suite hanging indefinitely by adding timeouts and proper cleanup#366
mariuz merged 2 commits intomasterfrom
copilot/fix-test-errors-action-run

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 13, 2026

Tests hung indefinitely in CI, never completing. Root causes: no mocha timeout configuration, reconnect test waiting for events without error handling, and after hooks calling db.detach() without callbacks.

Changes

  • Added .mocharc.json with 10s timeout and exit: true to force completion
  • Fixed reconnect test to handle both success and failure paths:
    // Before: hung waiting for 'reconnect' event
    db.on('reconnect', function () {
      db.detach(done);
    });
    
    // After: handles errors, cleans up listeners
    var reconnectHandler = function () {
      db.removeListener('error', errorHandler);
      db.detach(done);
    };
    var errorHandler = function (err) {
      db.removeListener('reconnect', reconnectHandler);
      done(err);
    };
    db.on('reconnect', reconnectHandler);
    db.on('error', errorHandler);
  • Added callbacks to all after() hooks to await detach completion:
    // Before: returns immediately
    after(function() {
      if (db) db.detach();
    });
    
    // After: waits for detach
    after(function(done) {
      if (db) {
        db.detach(done);
      } else {
        done();
      }
    });

Results

Primary test suite (index.js): 41 passing in <1s, previously hung indefinitely.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: mariuz <18359+mariuz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix test errors in current action run and resolve timeout issues Fix test suite hanging indefinitely by adding timeouts and proper cleanup Feb 13, 2026
Copilot AI requested a review from mariuz February 13, 2026 15:40
@mariuz mariuz marked this pull request as ready for review February 13, 2026 15:53
@mariuz mariuz merged commit 0b4c066 into master Feb 13, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants